<?php
/* @var $this PostController */
/* @var $dataProvider CActiveDataProvider */

$this->breadcrumbs=array(
	'Posts',
);

$this->menu=array(
	array('label'=>'Create Post', 'url'=>array('create')),
	array('label'=>'Manage Post', 'url'=>array('admin')),
);
?>
<h2 class="post_header">Tin tức IzumiShop</h2>
<div class="post_container">
	<?php

	foreach ($post_data as $key => $value) {
		echo "<div class='section_post'>";
		echo "<div class='post_image'><img src='".Yii::app()->request->baseUrl."/images/posts/".$value->image_link."' alt='".$value->post_title."'/></div>";  
		echo "<div class='post_content'>";
		echo "<h3 class='post_title'><a href='".Yii::app()->request->baseUrl."/post/".$value->id."'>".$value->post_title."</a></h3>";
		echo "<div class='post_description'>";
		
		$string = strip_tags($value->post_content);
		$words = preg_split("/[\n\r\t ]+/", $string, 80, PREG_SPLIT_NO_EMPTY);
    	array_pop($words);
        $post_description = implode(' ', $words);
        $post_description = $post_description . " ...";
		echo $post_description."</div>";
		echo '<div class="clear author_category">';
		echo "<span style='margin-right:20px;'>Người viết: <strong>".$value->author->username."</strong></span>";
		echo "<span style='margin-right:20px;'>Ngày viết: <strong>".date("d-m-Y", strtotime($value->created))."</strong></span>";
		echo "<span>Tin tức: <a href='".Yii::app()->request->baseUrl."/index.php/grouppost/view/".$value->group_post->id."'><strong>".$value->group_post->group_name."</strong></a></span>";
		echo '</div>';
		echo "</div></div>";
	}

	echo "<div class='pagination'>";
	$this->widget('CLinkPager', array(
		'pages'=>$pages,
	));

	$this->widget('CListPager', array(
		'pages'=>$pages,
	));
	echo "</div>";
	?>
 </div>